package com.gmail.dmitryustimov.ms.observer.java7_innerclasses;


public class Subscriber {

    String name;
    Writer writer;

    public Subscriber(Writer author, String name) {
        this.name = name;
        this.writer = author;
        this.writer.bookEventPublisher.subscribe(this.new BookProcessor());
        this.writer.articleEventPublisher.subscribe(this.new ArticleProcessor());
    }

    public class BookProcessor implements SubscribeAction<Book> {
        @Override
        public void process(Book book) {
            System.out.println(name + " is processing: " + book);
        }
    }

    public class ArticleProcessor implements SubscribeAction<Article> {
        @Override
        public void process(Article article) {
            System.out.println(name + " is processing: " + article);
        }
    }
}
